<?php

use Attribute;

#[Attribute(Attribute::TARGET_METHOD)]
class MyAttribute
{
    const VALUE = 20;

    private $value;

    /**
     * @param $value
     */
    public function __construct($value)
    {
        $this->value = $value;
    }

}
#[Attribute(Attribute::TARGET_PROPERTY)]
class MyPropertiesAttribute
{
    private $uri;
    private $port;

    /**
     * @param $uri
     * @param $port
     */
    public function __construct($uri, $port)
    {
        $this->uri = $uri;
        $this->port = $port;
    }

}

#[MyAttribute(38)]
class Thing
{
    #[MyPropertiesAttribute(uri: 50, port: ['php','java'])]
    public mixed $use;
}

$thing = new Thing();
$reflection = new ReflectionClass($thing);

$attributes = $reflection->getAttributes();

foreach ($attributes as $attribute) {
    var_dump($attribute->getTarget(), $attribute->getName(), $attribute->getArguments());
}

$properties = $reflection->getProperties();
foreach ($properties as $property) {
    $attributes = $property->getAttributes();
    foreach ($attributes as $attribute) {
        $thing->{$property->getName()} = $attribute->getArguments();
    }
}



var_dump($thing);

exit('end TestAttributes');